import { BUSINESS_NODES } from '@/config'

const defaultValue = {
  nodeBusinessData: [],
  nodeUIData: {
    nodes: [],
    edges: [],
  },
  categoryHeights: {},
}
export default {
  method: 'get',
  url: '/api/logs/config_data',
  transformParam: ({ businessName }) => {
    return {
      key: `${BUSINESS_NODES}-${businessName}`,
    }
  },
  defaultValue,
  transformResponse: response => {
    const { data = {} } = response

    const { content } = data
    try {
      const result = content === '' ? defaultValue : JSON.parse(content)
      return result
    } catch (e) {
      console.error('getBusinessData error', e)
      return []
    }
  },
}
